package com.cysyz.mylib.mylibtools.httpclient;

import org.apache.http.client.protocol.HttpClientContext;

import java.util.Map;

public interface HttpRequestProxy {
/**
	 * 用法： HttpRequestProxy hrp = new HttpRequestProxy();
	 * hrp.doRequest("http://www.163.com",null,null,"gbk");
	 *
	 * @param url
	 *            请求的资源ＵＲＬ
	 * @param postData
	 *            POST请求时form表单封装的数据 没有时传null
	 * @param header
	 *            request请求时附带的头信息(header) 没有时传null
	 * @param encoding
	 *            response返回的信息编码格式 没有时传null
	 * @return response返回的文本数据
	 * @throws HttpRequestProxyException
	 *//*

	public abstract String doRequest(String url, Map<String, String> postData,
			Map<String, String> header, String encoding) throws HttpRequestProxyException;

	*/
/**
	 * 特殊请求数据,这样的请求往往会出现redirect本身而出现递归死循环重定向 所以单独写成一个请求方法
	 * 比如现在请求的url为：http://localhost:8080/demo/index.jsp 返回代码为302
	 * 头部信息中location值为:http://localhost:8083/demo/index.jsp
	 * 这时httpclient认为进入递归死循环重定向，抛出CircularRedirectException异常
	 *
	 * @param url
	 * @return
	 * @throws HttpRequestProxyException
	 *//*

	public abstract String doSpecialRequest(String url, int count,
			String encoding);

*/
	byte[] doGet(String url, Map<String, String> header);

	byte[] doGet(String url);

	byte[] doPost(String url, Map<String, String> postData);

	byte[] doPost(String url, Map<String, String> postData,
			Map<String, String> header);


	byte[] doPost(String url, Map<String, String> postData, HttpClientContext context);

	byte[] doPost(String url, Map<String, String> postData, Map<String, String> header, HttpClientContext context);
}